/**
 * Created by huaicheng151201@163.com on 2017/9/29 0029.
 * Author : dhc
 * summary : null
 */
var urlHead = GetQueryString("urlHead");
var classId = GetQueryString("id");
$(function () {
    getVideoDetails();
    $(".v_share").load("share.html");
    $(".v_share").height( window.innerHeight + "px" );
    // 返回上一步
    $(".return").on("tap",function () {
        history.back();
    });
    // 打开分享功能
    $(".share").on("tap",function () {
        $(".v_share,.share_box").removeClass("hide");
    });
});

// 获取视频详情
function getVideoDetails(){
    $.ajax({
        url : urlHead + "/AppApi/SelectAppDubdetails",
        type: "post",
        dataType : "json",
        data : { "id" : classId },
        success : function (data) {
            console.log( data );
            if( data.Code == 1 ){
                $(".video_box video").attr("src",data.data.video);
                $(".details_box .details_title").html( data.data.title );
                $(".about").html( "简介："+data.data.about );
                $(".details_box .details_time").html('' +
                    '<span><b></b>'+data.data.name+'</span>' +
                    '<span><b></b>'+data.data.amountofplay+'次</span>' +
                    '<span><b></b>'+data.data.date+'</span>'
                );
                var list = data.data.row;
                console.log(list);
                var relatedVideo = "";
                for( var i=0;i<list.length;i++ ){
                    relatedVideo += '<li data-id="'+list[i].id+'" data-about="'+list[i].about+'">' +
                        '<div class="details_msg">' +
                        '<img src="'+list[i].img+'" alt="">' +
                        '<p class="l_play"><img src="images/vision_play.png" alt=""></p>' +
                        '<p class="l_title"><span>'+list[i].dclassify+'</span></p></div>' +
                        '<div class="details_title">'+list[i].title+'</div>' +
                        '<div class="details_other">' +
                        '<span><b></b>'+list[i].name+'</span>' +
                        '<span><b></b>'+list[i].amountofplay+'次</span>' +
                        '<span><b></b>9.14</span></div>' +
                        '</li>';
                }
                $(".related_details").html( relatedVideo );
            }
        }
    })
}

// 获取url地址栏参数
function GetQueryString(name){
    var reg = new RegExp("(^|&)"+ name +"=([^&]*)(&|$)");
    var r = window.location.search.substr(1).match(reg);
    if(r!=null)return  unescape(r[2]);return null;
}